<template>
    <div class="list" v-if="userList">
        <h2>用户列表</h2>
        <el-row >
            <el-table :data="userList" style="width: 100%">
                <el-table-column label="id" width="180" border >
                    <template #default="scope">
                        {{scope.row._id}}
                    </template>
                </el-table-column>
                <el-table-column  label="用户名" width="180" >
                    <template #default="scope">
                        {{scope.row.username}}
                    </template>
                </el-table-column>
                <el-table-column  label="手机号" >
                    <template #default="scope">
                            {{scope.row.phone}}
                        </template>
                </el-table-column>
                <el-table-column  label="注册时间" >
                    <template #default="scope">     
                            <span v-if="scope.row.time">
                                {{scope.row.time }}
                            </span>
                        </template>
                </el-table-column>
                <el-table-column  label="权限级别">
                    <!-- <template #default="scope">      -->
                                <!-- {{roleList.find(item=>item.value==scope.row.role).namestar}} -->
                        <!-- </template> -->
                </el-table-column>
                <el-table-column label="操作" />
            </el-table>
        </el-row>
    </div>
</template>

<script>
import { onMounted, reactive, toRefs ,ref } from '@vue/runtime-core'
import { useStore } from 'vuex'
import {ajax} from "@/api"
export default {
    setup(props){
        const store = useStore()
         const state = reactive({
             userList:null
         })
         const getUserList = async ()=>{
            let res= await ajax.getUserList()
            state.userList = res.data;
        }
         onMounted(()=>{
            getUserList()
        })
        return{
            ...toRefs(state),
          
        }
    }
}
</script>

